#include "console.h"
#include "mmu.h"
#include "plic.h"
#include "proc.h"
#include "riscv.h"
#include "stdio.h"
#include "time.h"
#include "trap.h"
#include "type.h"
#ifndef QEMU
#include "fs/dmac.h"
#include "fs/fpioa.h"
#include "fs/sdcard.h"
#endif
#include "fs/disk.h"
#include "fs/fat32.h"
#include "fs/file.h"

#include "dbg.h"

int start = 0;
int
main(register_t hartid) {
    w_tp(hartid);
    if (hartid == 0) {
        // setNextTime();
        console_init();
        printinit();
        kinit();
        kvminit();
        kvminithart();
        kmm_init();
        timerInit();
        trapinithart();
        proc_init();
        plicinit();
        plicinithart();
#ifndef QEMU
        fpioa_pin_init();
        dmac_init();
#endif
        disk_init();
        file_init();
        //  fat32_init();
        // TODO: fs init
        creat_first_proc();
      //  __DEBUG_INFO(creat_first_proc() over);
        printf("hart0 init done\n");
        scheduler();
    } else {
        while (1)
            ;
    }
    return 0;
}